<template>
  <div>
    <div style="margin-top:20px;">
      <div
        class="NewsList-content-item"
        @click="skipRouter({path:'/newDetails',query:{newsId:item.newsId}})"
        v-for="(item, index) in list"
        :key="index"
      >
        <div v-show="!item.titleImg">
          <div class="title">{{item.title}}</div>
          <div class="newsAbsrtact">{{item.newsAbstract}}</div>
          <div class="tagAndTime">
            <div class="tag">
              <van-tag v-show="index<9" plain type="danger" size="medium">置顶</van-tag>
            </div>
            <div class="time">{{item.createTime.split(" ")[0]}}</div>
          </div>
        </div>
        <div v-show="item.titleImg" class="newsItemBox">
          <div class="newsItemLeft">
            <div class="title omit-3">{{item.title}}</div>
            <div class="timeAndTag">
              <div class="time">{{item.createTime.split(" ")[0]}}</div>
              <div class="tag">
                <van-tag v-show="index<9" plain type="danger" size="medium">置顶</van-tag>
              </div>
            </div>
          </div>
          <div class="newsItemRight">
            <img :src="imgUrl+item.titleImg" alt />
          </div>
        </div>

        <van-divider />
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'newsItem',
  props: {
    list: {
      type: Array,
      default() {
        return []
      },
    },
  },
  data() {
    return {
      imgUrl: config.imgUrl,
    }
  },
  methods: {
    skipRouter(routerObj) {
      this.$router.push(routerObj)
    },
  },
}
</script>
<style lang="scss">
@import '@/assets/css/base';
.NewsList-content-item {
  // margin-top: px2rem(40);
  text-align: justify;
  .title {
    font-size: px2rem(36);
    color: #000000;
    line-height: px2rem(56);
    // font-weight: 400;
  }
  .newsAbsrtact {
    color: #969799;
    font-size: px2rem(32);
    line-height: px2rem(52);
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    display: -webkit-box;
    margin-top: px2rem(10);
  }
  .tagAndTime {
    display: flex;
    justify-content: space-between;
    line-height: px2rem(40);
    .time {
      font-size: px2rem(28);
      color: #969799;
      padding-top: px2rem(24);
      padding-right: px2rem(20);
    }
  }
  .newsItemBox {
    display: flex;
    justify-content: space-between;
    .newsItemLeft {
      width: 60%;
      .timeAndTag {
        display: flex;
        .time {
          font-size: px2rem(28);
          color: #969799;
          padding-top: px2rem(10);
          padding-right: px2rem(20);
          line-height: px2rem(40);
        }
        .tag {
          line-height: px2rem(10);
        }
      }
    }
    .newsItemRight {
      width: 37%;
      & > img {
        width: 100%;
        height: 100%;
        border-radius: 5px;
        object-fit: cover;
      }
    }
  }
  .omit-3 {
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    display: -webkit-box;
  }
}
</style>